#include<bits/stdc++.h>
using namespace std;
const int con=100300;
int m,n,d[con],v[con],a[con],pmax,p[con],l,vmax,tot;
bool f(int vv0,int aa0,int xx0)
{
	return vmax*vmax-vv0*vv0<(pmax-xx0)*aa0*2;
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);
	int t;
	cin>>t;
	while(t--)
	{
		tot=0,pmax=0;
		cin>>n>>m>>l>>vmax;
		for(int i=1;i<=n;++i)
		{
			cin>>d[i]>>v[i]>>a[i];
		}
		for(int i=1;i<=m;++i)
		{
			cin>>p[i];
			pmax=max(pmax,p[i]);
		}
		for(int i=1;i<=n;++i)
		{
			if(d[i]<=pmax&&(f(v[i],a[i],d[i])||(a==0&&v[i]>vmax))) tot++;
		}
		if(tot==0)m++;
		cout<<tot<<" "<<m-1<<"\n";
		//cout<<pmax<<endl;
	}
	return 0;
}
